package interfac.base;

import org.apache.commons.lang3.tuple.Pair;
import org.testng.annotations.Test;

import java.util.Arrays;

public class Execute {

    @Test
    public void t1() {


        Animal animal = new Dog();
        animal.eat();
        animal.speed();

        Dog dog = new Dog();
        dog.eat();
        dog.speed();

        // 接口的成员变量的使用方式
        System.out.println(Animal.type);
        // 使用接口的静态方法的方式
        Animal.sleep();



    }

    @Test
    public Pair<int[], Long> getMaxArray() {
        int[] a = {-2,1,-3,4,-1,2,1,-5,4};

        int[] sortedA = Arrays.stream(a)
                .sorted()
                .filter(i -> i > 0)
                .toArray();

        System.out.println(Arrays.toString(sortedA));
        long sum = Arrays.stream(sortedA)
                .mapToLong(i -> i)
                .sum();

        return Pair.of(sortedA, sum);
    }

    public static void main(String[] args) {
        int[] a = {-2,1,-3,4,-1,2,1,-5,4};

        int[] sortedA = Arrays.stream(a)
                .sorted()
                .filter(i -> i > 0)
                .toArray();

        System.out.println(Arrays.toString(sortedA));
        Arrays.stream(sortedA).mapToLong(i -> i).sum();
    }
}
